@extends('frontend/layouts/bootstrap')

@section('content')

<div>
    <span style="font-size: 31.5px;  line-height: 60px;  margin: 10px 0;  font-family: inherit;  font-weight: bold;  color: inherit;  text-rendering: optimizelegibility;  -webkit-margin-before: 0.83em;  -webkit-margin-after: 0.83em;  -webkit-margin-start: 0px;  -webkit-margin-end: 0px;"> MoneyExchange Management</span>
    {{ link_to_route('car_balance.money_exchange.create', 'Add new MoneyExchange', null, array('class' => 'btn btn-info', 'style' => 'float: right; margin: 20px 0 10px 0;')) }}
</div>

{{-- FILTER --}}
<div class="well well-small">
    <form class="form-inline" style="margin: 0;" action="{{ route('car_balance.money_exchange.index') }}" method="get">
        {{-- MoneyExchange filter --}}
        <td>
            <input class="input-small" placeholder="日付" type="text" name="recieve_date" id="daterange" value="{{ count($filter_recieve_date) > 1 ? $filter_recieve_date[0] .' - '.$filter_recieve_date[1] : '' }}"/>
        </td>
        {{ Form::select('customer_id', $customer_list, $filter_customer_id, array('class' => 'input-small')) }}
        {{-- Form::token() --}}
        {{-- BUTTONS --}}
        <button type="submit" class="btn">Apply Filter</button>
        <a href="{{ route('car_balance.money_exchange.index') }}" >Reset</a>
    </form>
</div>

@if ($money_exchanges->count())
<div>{{ $money_exchanges->getTotal() }} results.</div>
<table class="table table-bordered table-striped table-hover">
    <thead>
    <tr>
        <th class="span2">Actions</th>
        <th>Recieve Date</th>
        <th>Customer</th>
        <th style="text-align: center;">Amount Tugrug</th>
        <th style="text-align: center;">Exchange Rate</th>
        <th style="text-align: center;">Amount Yen</th>
        <th style="text-align: center;">Amount total</th>
    </tr>
    </thead>
    <tbody>
    @foreach ($money_exchanges as $money_exchange)
    <tr>
        <td>
            <a class="btn btn-primary btn-mini" href="{{ route('car_balance.money_exchange.show', $money_exchange->id) }}" title="Detial"><i class="icon-zoom-in icon-white"></i></a>
            <a class="btn btn-primary btn-mini" href="{{ route('car_balance.money_exchange.edit', $money_exchange->id) }}" title="Edit"><i class="icon-dollar icon-white"></i></a>
        </td>
        <td>{{  $money_exchange->recieve_date }}</td>
        <td>{{  $money_exchange->customer()->first() ? link_to_route('car_balance.customer.show', $money_exchange->customer()->first()->name, array('id' => $money_exchange->customer()->first()->id), array()) : 'NULL' }}</td>
        <td style="text-align: right;" >{{  $money_exchange->amount_tugrug ? number_format($money_exchange->amount_tugrug, 0) : 0; }}</td>
        <td style="text-align: right;" >{{  $money_exchange->exchange_rate ? number_format($money_exchange->exchange_rate, 2) : 0; }}</td>
        <td style="text-align: right;" >{{  $money_exchange->amount_yen ? number_format($money_exchange->amount_yen, 0) : 0; }}</td>
        <td style="text-align: right;" >{{  $money_exchange->amount ? number_format($money_exchange->amount, 0) : 0; }}</td>
    </tr>
    @endforeach
    </tbody>
</table>

@include('nimo/domains/car_balance/page')

@else
Хайлтад тохирох үр дүн алга
@endif

@stop

@section('pagestyles')
<link rel="stylesheet" type="text/css" href={{ asset('assets/chosen-bootstrap/chosen.min.css') }} />
<link rel="stylesheet" type="text/css" href={{ asset('assets/bootstrap-daterangepicker/daterangepicker.css') }} />
<style type="text/css" media="screen">
</style>

@stop

@section('pagescripts')
<!--page specific plugin scripts-->
<script type="text/javascript" src={{ asset('assets/chosen-bootstrap/chosen.jquery.min.js') }}></script>
<script type="text/javascript" src={{ asset('assets/bootstrap-daterangepicker/date.js') }} ></script>
<script type="text/javascript" src={{ asset('assets/bootstrap-daterangepicker/daterangepicker.js') }}></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('input[name="recieve_date"]').daterangepicker({
            format:"yyyy/MM/dd"
        });
    });
</script>
@stop